<?php
//Function to send a mail from a gmail account
    function sendMail($message, $mail_recipient,$sujet){
        
        //mise en forme du message
        $content = "<p>$message</p>";
        
       //adresse email d'envoi
        $mail_user = 'inscription.valrando@gmail.com';

        //Ajout des classes nécessaires
        require_once("phpmailer/class.phpmailer.php");
        require_once("phpmailer/class.smtp.php");

        //Création de l'email
        $mail = new PHPMailer();
        $mail->SetLanguage("fr", 'phpmailer/language/'); // set language
        $mail->IsSMTP(); // telling the class to use SMTP
        $mail->SMTPAuth = true; // enable SMTP authentication
        $mail->SMTPDebug = 0; // disable debug mode
        $mail->SMTPSecure = 'ssl'; // sets the prefix to the servier
        $mail->Host = 'smtp.gmail.com'; //sets the SMTP server 
        $mail->Port = 465; // sets the SMTP port for the server
        $mail->Username = $mail_user; // username
        $mail->Password = 'inscrValrando'; // password
        $mail->From = $mail_user; // email from
        $mail->FromName = 'Valrando'; //name of the mailer
        $mail->Subject = $sujet;
        $mail->CharSet = 'UTF-8'; 
        $mail->ContentType = 'text/plain; charset="UTF-8"';
        $mail->AddAddress($mail_user);
        //The recipient
        $mail->AddCC($mail_recipient);
        $mail->MsgHTML($content); //body
        //Sending
        $mail->Send();
    }
?>